<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Chat/classes/PhpFox_ComponentWhoIsOnline.class.php, $Author:  $ */



/** Chat component
 * 
 * @package module.chat
 * @version $Id: PhpFox_ComponentWhoIsOnline.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 *   PHPFox Team ()
 */
class PhpFox_Mod_Chat_ComponentWhoIsOnline extends BaseComponent
{
    function process()
	{
        $oAcc = $this->getParam('oUser');
	    assert($oAcc != null);
	    
	    $oSrvAccount = &App::getModuleService('Account', 'Security');
	    $oReq = &App::getRequest();
	    $oSrvChat = &$this->_oModule->getService('Chat');
		    
        $iUserChatId = $oSrvChat->checkUserStatusYShout($oAcc->aData['user']);
        if(!$iUserChatId)
            $oSrvChat->updateUserOnlineYShout($oAcc->aData['user']);
        else
            $oSrvChat->updateUserOnlineYShout($oAcc->aData['user'], $iUserChatId);

        $aOnline = $oSrvChat->getUserOnlineYShout();
        $sDiv = '';
        foreach($aOnline as $i=>$aUser)
        {
            $sStyle = ($i%2) ? ' class="border13"' : '';
            $sDiv .= '<div style="padding:5px;"'.$sStyle.'>
						<img src="'.App::getParam('user.pic.url').$aUser['user'].'_20.jpg" alt="" class="pic1" 
						onmouseover="showInfo5(\''.$aUser['user'].'\', \'\', \'\');
						this.className=\'pic2\';" onmouseout="this.className=\'pic1\';return nd();" /> '.
                        $aUser['user'].'</div>';
        }
        $oTpl = &$this->_oModule->getTemplate();
        
        $sHtml = $oTpl->fetch('WhoIsOnline.html');
        return ($oReq->get('online')) ? $sHtml : $sDiv;
	}
}
?>